<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<style>

#anchor {
    display: block;
    position: absolute;
    width: 60px;
    height: 30px;
    background-color: #eee;
    font: bold 10pt monospace;
    padding: 10px;
    left: 200px;
    top: 150px;
}

</style>
<a id="anchor" name="foo">ANCHOR</a>
<script>

description("Tests that the scroll position does not stick to the anchor if " +
            "it moves after the page has finished loading.");

var jsTestIsAsync = true;
var anchor = document.querySelector("#anchor");

onload = function() {
    runAfterLayoutAndPaint(function() {
        location.hash = "#foo";

        runAfterLayoutAndPaint(function() {
            anchor.style.top = "1000px";

            shouldBe("scrollY", "0");

            location.hash = "#";
            anchor.style.top = "";
            finishJSTest();
        });
    });
};

</script>
